import socket
import time


def TestClient():
    server_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_client.connect(("localhost", 8888))

    info = "How are you?"
    while True:
        server_client.send(bytes(info, encoding='utf-8'))
        print("send   : ", info)
        recv_str = server_client.recv(1024)
        if not recv_str:
            break
        print("receive: ", recv_str.decode("utf-8"))
        time.sleep(0.5)

    server_client.close()
    print("server end, exit!")
    exit()


if __name__ == '__main__':
    TestClient()
